# xnvme_tests_znd_state completion                           -*- shell-script -*-
#
# Bash completion script for the `xnvme_tests_znd_state` CLI
#
# SPDX-FileCopyrightText: Samsung Electronics Co., Ltd
#
# SPDX-License-Identifier: BSD-3-Clause

_xnvme_tests_znd_state_completions()
{
    local cur=${COMP_WORDS[COMP_CWORD]}
    local sub=""
    local opts=""

    COMPREPLY=()

    # Complete sub-commands
    if [[ $COMP_CWORD < 2 ]]; then
        COMPREPLY+=( $( compgen -W 'transition changes --help' -- $cur ) )
        return 0
    fi

    # Complete sub-command arguments

    sub=${COMP_WORDS[1]}

    if [[ "$sub" != "enum" ]]; then
        opts+="/dev/nvme* "
    fi

    case "$sub" in
    
    "transition")
        opts+="--nsid --slba --subnqn --hostnqn --be --dev-nsid --admin --mem --direct --sync --help"
        ;;

    "changes")
        opts+="--nsid --subnqn --hostnqn --be --dev-nsid --admin --mem --direct --sync --help"
        ;;

    esac

    COMPREPLY+=( $( compgen -W "$opts" -- $cur ) )

    return 0
}

#
complete -o nosort -F _xnvme_tests_znd_state_completions xnvme_tests_znd_state

# ex: filetype=sh
